﻿using CJAtech.BBS.Process;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CJAtech.BBS.Web.Controllers
{
    public partial class BBSController
    {
        public ActionResult Index(int? categoryId)
        {
            //todo:判断版块是否存在
            //return Content("123");
            //return Content(CurrentCommunityConfig.ConnectionString);
            return BBSView();
        }
        public ActionResult UserArticles()
        {
            return BBSView();
        }

        /// <summary>
        /// 文章详情页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Article(int? id)
        {
            if (!id.HasValue)
            {
                return Http404();
            }
            ArticleInfoProcess objArticleInfoProcess = new ArticleInfoProcess(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            ArticleResultInfo objArticleResultInfo = objArticleInfoProcess.GetArticleResultInfo(id.Value, false, false);
            if (objArticleResultInfo == null || objArticleResultInfo.ArticleInfo == null)
            {
                return Http404();
            }
            if (objArticleResultInfo.ArticleInfo.IsRelease != 1 && !string.Equals(objArticleResultInfo.ArticleInfo.ObjectId, this.CurrentUserInfo.UserId))
            {
                return Content("对不起，当前文章还在审核中");
            }
            //更新文章的浏览数
            objArticleInfoProcess.IncreaseViewCount(id.Value);

            return BBSView();
        }

        public ActionResult Publish()
        {
            return BBSView();
        }
    }
}
